//
//  settingVC.m
//  CMAccountBook
//
//  Created by 王开政 on 2018/10/31.
//  Copyright © 2018年 王开政. All rights reserved.
//

#import "settingVC.h"
#import "personVC.h"
@interface settingVC ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic, strong) UITableView *Tab;

@end

@implementation settingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self navig];
    [self.view addSubview:self.Tab];
    
    // Do any additional setup after loading the view.
}
#pragma mark-自定义导航区
-(void)navig{
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
    self.navigationController.navigationBarHidden=YES;
    __weak typeof(self) weakself = self;
    HomeNavigation*navView = [[HomeNavigation alloc]initWithTag:1 title:@"设置" handler:^(UIButton *sender) {
        [weakself backPress];
    }];
    [self.view addSubview:navView];
    
}
-(void)backPress{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}
-(UITableView *)Tab{
    
    if (!_Tab) {
        _Tab = [[UITableView alloc]initWithFrame:CGRectMake(0,SafeAreaTopHeight, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
        _Tab.backgroundColor = [UIColor colorWithHexString:@"#f5f5f5"];
        _Tab.delegate = self;
        _Tab.dataSource = self;
        //        self.myTab.scrollEnabled = NO;
        _Tab.showsVerticalScrollIndicator = NO;
        _Tab.tableFooterView.backgroundColor = [UIColor colorWithHexString:@"#f5f5f5"];
        if(@available(iOS 11.0, *)){
            _Tab.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
            _Tab.estimatedRowHeight = 0;
            _Tab.estimatedSectionHeaderHeight = 0;
            _Tab.estimatedSectionFooterHeight = 0;
            
        }
        
    }
    
    return _Tab;
}
#pragma mark -设置cell横线左顶边
-(void)viewDidLayoutSubviews {
    if ([self.Tab respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.Tab setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([self.Tab respondsToSelector:@selector(setLayoutMargins:)])  {
        [self.Tab setLayoutMargins:UIEdgeInsetsZero];
    }
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
#pragma  make - UITableViewDataSource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 2;
}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0) {
        return 1;
    }
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
    if (!cell) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        
    }
    cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            cell.textLabel.text = @"个人信息";
        }
    }else if (indexPath.section == 1){
        if (indexPath.row == 0) {
            cell.accessoryType =UITableViewCellAccessoryNone;
            cell.textLabel.text = @"意见反馈";
        }else if (indexPath.row == 1){
            cell.textLabel.text = @"关于我们";
        }else if (indexPath.row == 2){
            cell.textLabel.text = @"分享给好友";
        }else if (indexPath.row == 3){
            cell.textLabel.text = @"帮助";
        }else if (indexPath.row == 4){
            cell.textLabel.text = @"隐私政策";
        }
    }
    return cell;
}

#pragma  make - UITableViewDelegate
//返回高度，计算不同高度cell 一定要用，否则会出现偏移
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    return 50;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view =[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
    view.backgroundColor = [UIColor colorWithHexString:@"#F6F6F8"];
    //    UILabel *leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(21*kfit, 0, ScreenWidth/2, 35)];
    //    leftLabel.textColor = [UIColor colorWithHexString:@"#B7B7B7"];
    //    leftLabel.font = [UIFont systemFontOfSize:10*kfit];
    //    leftLabel.textAlignment = NSTextAlignmentLeft;
    //    leftLabel.text =self.sectionArray[section][@"data"];
    //
    //    UILabel *rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2 -21*kfit, 0, ScreenWidth/2, 35)];
    //    rightLabel.textColor = [UIColor colorWithHexString:@"#B7B7B7"];
    //    rightLabel.font = [UIFont systemFontOfSize:10*kfit];
    //    rightLabel.textAlignment = NSTextAlignmentRight;
    //    rightLabel.text =self.sectionArray[section][@"money"];
    //
    //    [view addSubview:leftLabel];
    //    [view addSubview:rightLabel];
    
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            
            personVC *VC = [[personVC alloc]init];
            self.navigationController.navigationBarHidden=NO;
            [VC setHidesBottomBarWhenPushed:YES];
            [self.navigationController pushViewController:VC animated:YES];
        }
    }else if (indexPath.section == 1){
        if (indexPath.row == 0) {
            
            
        }else if (indexPath.row == 1){
            
        }else if (indexPath.row == 2){
            
        }else if (indexPath.row == 3){
            
        }else if (indexPath.row == 4){
            
        }
    }
    
    
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
